//
//  YAYIApilyListCell.m
//  YAYIDoctor
//
//  Created by hxp on 16/5/4.
//  Copyright © 2016年 hxp. All rights reserved.
//

#import "YAYIApilyListCell.h"

@implementation YAYIApilyListCell

- (void)awakeFromNib {
    [super awakeFromNib];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    
}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle: style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createViews];
    }
    return self;
}
-(void)createViews
{
    self.avatar = [UIImageView new];
    self.avatar.clipsToBounds = YES;
    self.avatar.image = [UIImage imageNamed:@"1"];
    self.avatar.contentMode = UIViewContentModeScaleAspectFill;
    [self.contentView  addSubview:self.avatar];
    
    self.name = [UILabel new];
    self.name.font = [UIFont systemFontOfSize:font14];
    self.name.textColor = [UIColor lightGrayColor];
    [self.contentView addSubview:self.name];
    self.dateLab = [UILabel new];
    self.dateLab.font = [UIFont systemFontOfSize:font14];
    self.dateLab.textColor = [UIColor lightGrayColor];
    self.dateLab.textAlignment = NSTextAlignmentRight;
    [self.contentView addSubview:self.dateLab];
    
    self.seprateLine = [UILabel new];
    self.seprateLine.backgroundColor = YAYIColor(0xdd, 0xdd, 0xdd);
    [self.contentView addSubview:self.seprateLine];

}

-(void)setModel:(YAYIMYPatientModel *)model{
    _model = model;
    [self reloadData];
}
-(void)reloadData
{
    [self.avatar sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",API,_model.avatar]] placeholderImage:[UIImage imageNamed:@"1"] completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
        
    }];
    self.dateLab.text  = _model.bookingtimestart;
    self.name.text = [NSString stringWithFormat:@"%@ (%@)",_model.patientname,_model.clientname];
}
-(void)layoutSubviews
{
    [super layoutSubviews];
    self.avatar.layer.cornerRadius = 45/2.0;
    [self.avatar mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.contentView.mas_centerY);
        make.left.equalTo(@(16));
        make.size.mas_equalTo(CGSizeMake(45, 45));
    }];
    [self.name mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.avatar.mas_right).with.offset(10);
        make.centerY.mas_equalTo(self.avatar.mas_centerY);
        make.size.mas_equalTo(CGSizeMake(160, 20));
    }];
    [self.dateLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(self.contentView.mas_right).with.offset(-18);
        make.centerY.mas_equalTo(self.avatar.mas_centerY);
        make.size.mas_equalTo(CGSizeMake(160, 20));
    }];
    [self.seprateLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0);
        make.bottom.mas_equalTo(self.contentView.mas_bottom).with.offset(0);
        make.size.mas_equalTo(CGSizeMake(SCREEN_width, 0.5));
    }];
}
@end
